<?php
/* -----------------------------------------------------------------
 * 	$Id: event_rss.php 1432 2015-02-05 15:03:00Z akausch $
 * 	Copyright (c) 2011-2021 commerce:SEO by Webdesign Erfurt
 * 	http://www.commerce-seo.de
 * ------------------------------------------------------------------
 * 	based on:
 * 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
 * 	(c) 2002-2003 osCommerce - www.oscommerce.com
 * 	(c) 2003     nextcommerce - www.nextcommerce.org
 * 	(c) 2005     xt:Commerce - www.xt-commerce.com
 * 	Released under the GNU General Public License
 * --------------------------------------------------------------- */

include ('includes/application_top.php');
$Title = "Termin Feed von " . STORE_NAME;
$logo_url = HTTP_SERVER . DIR_WS_CATALOG . "templates/" . CURRENT_TEMPLATE . "/img/logo.gif";

$Description = "Neue Termine von " . STORE_NAME;
$copyright = STORE_NAME;
$category = "Einträge";
$date = date("r");
$days = date("d.m.Y", mktime(1, 1, 1, date(m), date(d) - 30, date(Y)));
$SiteLink = HTTP_SERVER . DIR_WS_CATALOG;
header("Content-Type: text/xml");
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
echo "<rss version=\"2.0\">\n\n";
echo "\t<channel>\n";
echo "\t\t<title>$Title</title>\n";
echo "\t\t<link>$SiteLink</link>\n";
echo "\t\t<description>$Description</description>\n";
echo "\t\t<language>de-de</language>\n";
echo "\t\t<copyright>$copyright</copyright>\n";
echo "\t\t<pubDate>$date</pubDate>\n";
echo "\t\t<image>\n\t\t\t<url>" . $logo_url . "</url>\n\t\t\t<title>Shoplogo</title>\n\t\t\t<link>" . $SiteLink . "</link>\n\t\t</image>\n\n";
	$group_check = '';
	if (GROUP_CHECK == 'true') {
		$mycust_rechte_query = xtc_db_query("select * from customer_status where customers_id = '".$_SESSION['customer_id']."'  ");
		$group_check .= " and (";
		while ($mycust_rechte = xtc_db_fetch_array($mycust_rechte_query)){
				$group_check .= " group_ids LIKE '%c_" . $mycust_rechte['status_id'] . "_group%' or ";
		}
		$group_check .= " group_ids LIKE 0) ";
		if($group_check ==''){
		  $group_check = "and group_ids LIKE '%c_" . $_SESSION['customers_status']['customers_status_id'] . "_group%' ";
		}
	}
$query = xtc_db_query("SELECT * FROM blog_items WHERE status = '2' AND calender != 0 AND language_id = '" . $_SESSION['languages_id'] . "' AND '" . $days . "' ".$group_check." ORDER BY id DESC");

while ($listing = xtc_db_fetch_array($query)) {
	 $image = xtc_db_fetch_array(xtc_db_query("select image from blog_item_images where item_id = ".$listing['item_id']." AND image_nr = 1 LIMIT 1 "));
	 if($image['image'] == ''){
		 $image_link = HTTP_SERVER . '/images/blog_image/original_images/no_img_big.jpg';
	 }else{
		 $image_link = HTTP_SERVER . '/images/blog_image/popup_images/' . $image['image'];
	 }
    $link = xtc_href_link(FILENAME_BLOG, 'blog_cat=' . $listing['categories_id'] . '&blog_item=' . $listing['item_id'], 'NONSSL', false);
    $blog_name = $listing['name'];
    $blog_name = str_replace("&", "&amp;", $blog_name);
    $blog_name = str_replace("\n", " ", $blog_name);

    echo "\t\t<item>\n";
    echo "\t\t\t<pubDate>" . $listing['date'] . "</pubDate>\n";
    echo "\t\t\t<category>" . $category . "</category>\n";
    echo "\t\t\t<title>" . $blog_name. "</title>\n";
    echo "\t\t\t<link>" . $link . "</link>\n";
    echo "\t\t\t<guid>" . $link . "</guid>\n";
    echo "\t\t\t<description><![CDATA[" . $listing['description'] . "\t\t\t\n\n<img src='" . $image_link . "' />]]></description>\n";
    echo "\t\t</item>\n\n";
}

echo "\t</channel>\n";
echo "</rss>";